using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Medianamik.Core.DAL.SubSonicDAL{
    /// <summary>
    /// Strongly-typed collection for the OneToManyRelation class.
    /// </summary>
    [Serializable]
    public partial class OneToManyRelationCollection : ReadOnlyList<OneToManyRelation, OneToManyRelationCollection>
    {        
        public OneToManyRelationCollection() {}
    }
    /// <summary>
    /// This is  Read-only wrapper class for the vw_medianamik_OneToManyRelation view.
    /// </summary>
    [Serializable]
    public partial class OneToManyRelation : ReadOnlyRecord<OneToManyRelation>, IReadOnlyRecord
    {
    
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_medianamik_OneToManyRelation", TableType.View, DataService.GetInstance("MedianamikProvider"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = @"dbo";
                //columns
                
                TableSchema.TableColumn colvarPrimaryPropertyId = new TableSchema.TableColumn(schema);
                colvarPrimaryPropertyId.ColumnName = "PrimaryPropertyId";
                colvarPrimaryPropertyId.DataType = DbType.Guid;
                colvarPrimaryPropertyId.MaxLength = 0;
                colvarPrimaryPropertyId.AutoIncrement = false;
                colvarPrimaryPropertyId.IsNullable = false;
                colvarPrimaryPropertyId.IsPrimaryKey = false;
                colvarPrimaryPropertyId.IsForeignKey = false;
                colvarPrimaryPropertyId.IsReadOnly = false;
                
                schema.Columns.Add(colvarPrimaryPropertyId);
                
                TableSchema.TableColumn colvarPrimaryTypeId = new TableSchema.TableColumn(schema);
                colvarPrimaryTypeId.ColumnName = "PrimaryTypeId";
                colvarPrimaryTypeId.DataType = DbType.Guid;
                colvarPrimaryTypeId.MaxLength = 0;
                colvarPrimaryTypeId.AutoIncrement = false;
                colvarPrimaryTypeId.IsNullable = false;
                colvarPrimaryTypeId.IsPrimaryKey = false;
                colvarPrimaryTypeId.IsForeignKey = false;
                colvarPrimaryTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarPrimaryTypeId);
                
                TableSchema.TableColumn colvarForeignPropertyid = new TableSchema.TableColumn(schema);
                colvarForeignPropertyid.ColumnName = "ForeignPropertyid";
                colvarForeignPropertyid.DataType = DbType.Guid;
                colvarForeignPropertyid.MaxLength = 0;
                colvarForeignPropertyid.AutoIncrement = false;
                colvarForeignPropertyid.IsNullable = false;
                colvarForeignPropertyid.IsPrimaryKey = false;
                colvarForeignPropertyid.IsForeignKey = false;
                colvarForeignPropertyid.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignPropertyid);
                
                TableSchema.TableColumn colvarForeignTypeId = new TableSchema.TableColumn(schema);
                colvarForeignTypeId.ColumnName = "ForeignTypeId";
                colvarForeignTypeId.DataType = DbType.Guid;
                colvarForeignTypeId.MaxLength = 0;
                colvarForeignTypeId.AutoIncrement = false;
                colvarForeignTypeId.IsNullable = false;
                colvarForeignTypeId.IsPrimaryKey = false;
                colvarForeignTypeId.IsForeignKey = false;
                colvarForeignTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignTypeId);
                
                TableSchema.TableColumn colvarPrimaryTypeName = new TableSchema.TableColumn(schema);
                colvarPrimaryTypeName.ColumnName = "PrimaryTypeName";
                colvarPrimaryTypeName.DataType = DbType.String;
                colvarPrimaryTypeName.MaxLength = 50;
                colvarPrimaryTypeName.AutoIncrement = false;
                colvarPrimaryTypeName.IsNullable = false;
                colvarPrimaryTypeName.IsPrimaryKey = false;
                colvarPrimaryTypeName.IsForeignKey = false;
                colvarPrimaryTypeName.IsReadOnly = false;
                
                schema.Columns.Add(colvarPrimaryTypeName);
                
                TableSchema.TableColumn colvarPrimaryPropertyName = new TableSchema.TableColumn(schema);
                colvarPrimaryPropertyName.ColumnName = "PrimaryPropertyName";
                colvarPrimaryPropertyName.DataType = DbType.String;
                colvarPrimaryPropertyName.MaxLength = 50;
                colvarPrimaryPropertyName.AutoIncrement = false;
                colvarPrimaryPropertyName.IsNullable = false;
                colvarPrimaryPropertyName.IsPrimaryKey = false;
                colvarPrimaryPropertyName.IsForeignKey = false;
                colvarPrimaryPropertyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarPrimaryPropertyName);
                
                TableSchema.TableColumn colvarForeignPropertyName = new TableSchema.TableColumn(schema);
                colvarForeignPropertyName.ColumnName = "ForeignPropertyName";
                colvarForeignPropertyName.DataType = DbType.String;
                colvarForeignPropertyName.MaxLength = 50;
                colvarForeignPropertyName.AutoIncrement = false;
                colvarForeignPropertyName.IsNullable = false;
                colvarForeignPropertyName.IsPrimaryKey = false;
                colvarForeignPropertyName.IsForeignKey = false;
                colvarForeignPropertyName.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignPropertyName);
                
                TableSchema.TableColumn colvarForeignTypeName = new TableSchema.TableColumn(schema);
                colvarForeignTypeName.ColumnName = "ForeignTypeName";
                colvarForeignTypeName.DataType = DbType.String;
                colvarForeignTypeName.MaxLength = 50;
                colvarForeignTypeName.AutoIncrement = false;
                colvarForeignTypeName.IsNullable = false;
                colvarForeignTypeName.IsPrimaryKey = false;
                colvarForeignTypeName.IsForeignKey = false;
                colvarForeignTypeName.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignTypeName);
                
                TableSchema.TableColumn colvarForeignTypeIsManyToMany = new TableSchema.TableColumn(schema);
                colvarForeignTypeIsManyToMany.ColumnName = "ForeignTypeIsManyToMany";
                colvarForeignTypeIsManyToMany.DataType = DbType.Boolean;
                colvarForeignTypeIsManyToMany.MaxLength = 0;
                colvarForeignTypeIsManyToMany.AutoIncrement = false;
                colvarForeignTypeIsManyToMany.IsNullable = false;
                colvarForeignTypeIsManyToMany.IsPrimaryKey = false;
                colvarForeignTypeIsManyToMany.IsForeignKey = false;
                colvarForeignTypeIsManyToMany.IsReadOnly = false;
                
                schema.Columns.Add(colvarForeignTypeIsManyToMany);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["MedianamikProvider"].AddSchema("vw_medianamik_OneToManyRelation",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public OneToManyRelation()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        public OneToManyRelation(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    public OneToManyRelation(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    public OneToManyRelation(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("PrimaryPropertyId")]
        [Bindable(true)]
        public Guid PrimaryPropertyId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("PrimaryPropertyId");
		    }
            set 
		    {
			    SetColumnValue("PrimaryPropertyId", value);
            }
        }
	      
        [XmlAttribute("PrimaryTypeId")]
        [Bindable(true)]
        public Guid PrimaryTypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("PrimaryTypeId");
		    }
            set 
		    {
			    SetColumnValue("PrimaryTypeId", value);
            }
        }
	      
        [XmlAttribute("ForeignPropertyid")]
        [Bindable(true)]
        public Guid ForeignPropertyid 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("ForeignPropertyid");
		    }
            set 
		    {
			    SetColumnValue("ForeignPropertyid", value);
            }
        }
	      
        [XmlAttribute("ForeignTypeId")]
        [Bindable(true)]
        public Guid ForeignTypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("ForeignTypeId");
		    }
            set 
		    {
			    SetColumnValue("ForeignTypeId", value);
            }
        }
	      
        [XmlAttribute("PrimaryTypeName")]
        [Bindable(true)]
        public string PrimaryTypeName 
	    {
		    get
		    {
			    return GetColumnValue<string>("PrimaryTypeName");
		    }
            set 
		    {
			    SetColumnValue("PrimaryTypeName", value);
            }
        }
	      
        [XmlAttribute("PrimaryPropertyName")]
        [Bindable(true)]
        public string PrimaryPropertyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("PrimaryPropertyName");
		    }
            set 
		    {
			    SetColumnValue("PrimaryPropertyName", value);
            }
        }
	      
        [XmlAttribute("ForeignPropertyName")]
        [Bindable(true)]
        public string ForeignPropertyName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ForeignPropertyName");
		    }
            set 
		    {
			    SetColumnValue("ForeignPropertyName", value);
            }
        }
	      
        [XmlAttribute("ForeignTypeName")]
        [Bindable(true)]
        public string ForeignTypeName 
	    {
		    get
		    {
			    return GetColumnValue<string>("ForeignTypeName");
		    }
            set 
		    {
			    SetColumnValue("ForeignTypeName", value);
            }
        }
	      
        [XmlAttribute("ForeignTypeIsManyToMany")]
        [Bindable(true)]
        public bool ForeignTypeIsManyToMany 
	    {
		    get
		    {
			    return GetColumnValue<bool>("ForeignTypeIsManyToMany");
		    }
            set 
		    {
			    SetColumnValue("ForeignTypeIsManyToMany", value);
            }
        }
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string PrimaryPropertyId = @"PrimaryPropertyId";
            
            public static string PrimaryTypeId = @"PrimaryTypeId";
            
            public static string ForeignPropertyid = @"ForeignPropertyid";
            
            public static string ForeignTypeId = @"ForeignTypeId";
            
            public static string PrimaryTypeName = @"PrimaryTypeName";
            
            public static string PrimaryPropertyName = @"PrimaryPropertyName";
            
            public static string ForeignPropertyName = @"ForeignPropertyName";
            
            public static string ForeignTypeName = @"ForeignTypeName";
            
            public static string ForeignTypeIsManyToMany = @"ForeignTypeIsManyToMany";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
}
